package com.bydq.patrolsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bydq.patrolsystem.entity.PsInspectiontaskDetail;
import com.bydq.patrolsystem.entity.PsSolvetaskMain;
import com.bydq.patrolsystem.mapper.PsInspectiontaskDetailMapper;
import com.bydq.patrolsystem.mapper.PsSolvetaskMainMapper;
import com.bydq.patrolsystem.service.PsSolvetaskMainService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 写代码是不可能写代码的啦~~
 * @since 2020-05-22
 */
@Service
public class PsSolvetaskMainServiceImpl extends ServiceImpl<PsSolvetaskMainMapper, PsSolvetaskMain> implements PsSolvetaskMainService {

    @Autowired
    PsSolvetaskMainMapper psSolvetaskMainMapper;

    @Override
    public IPage<PsSolvetaskMain> selectSolvetaskListByPaging(String solveTaskCode, String solveTaskName,
                                                              Long taskStatus, String issuedByName,
                                                              String startDate, String endDate, Integer page, Integer limit) {
        page = page == null ? 1 : page;
        limit = limit == null ? 3 : limit;
        QueryWrapper<PsSolvetaskMain> qw=new QueryWrapper<>();
        qw.like(solveTaskCode!=null&&solveTaskCode!="","solveTaskCode",solveTaskCode);
        qw.like(solveTaskName!=null&&solveTaskName!="","solveTaskName",solveTaskName);
        qw.like(issuedByName!=null&&issuedByName!="","issuedByName",issuedByName);
        qw.eq(taskStatus!=null,"taskStatus",taskStatus);
        qw.between(startDate!=null&&endDate!=null&&startDate!=""&&endDate!="","issuedTime",startDate,endDate);
        return psSolvetaskMainMapper.selectSolvetaskListByPaging(new Page<>(page, limit), qw);
    }
}
